//
//  AppDelegate.m
//  Home
//
//  Created by 杨泓晔 on 16/4/8.
//  Copyright © 2016年 LanJue. All rights reserved.
//

#import "AppDelegate.h"

#import "FindViewController.h" //寻找设计师的发现
#import "WUFindViewController.h"//我是设计师的发现

#import "YHYMViewViewController.h"
#import "UserTypeViewController.h"

#import "MainViewController.h"
#import "WUMineViewController.h"
#import "WUMessageViewController.h"  //寻找设计师的消息
#import "WUMessViewController.h"   //我是设计师的消息



@interface AppDelegate ()

@property (nonatomic, strong) UITabBarController *stabbar;
@property (nonatomic, strong) UITabBarController *ntabbar;
@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    
    self.window = [[UIWindow alloc]initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    
    //寻找设计师
    FindViewController *findVC = [[FindViewController alloc] init];
    UINavigationController *findNavC = [[UINavigationController alloc] initWithRootViewController:findVC];
    findVC.navigationController.interactivePopGestureRecognizer.enabled = YES;
    findNavC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"发现" image:[[UIImage imageNamed:@"tabbar_find"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_findS"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    
     WUMessageViewController *second = [[WUMessageViewController alloc] init];
     UINavigationController *messageNC = [[UINavigationController alloc] initWithRootViewController:second];
     messageNC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"消息" image:[[UIImage imageNamed:@"tabbar_message"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_messageS"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    

    
    //YHYMViewViewController
    WUMineViewController *MainVC = [[WUMineViewController alloc] init];
    UINavigationController *MainNavC = [[UINavigationController alloc] initWithRootViewController:MainVC];
    MainNavC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:[[UIImage imageNamed:@"tabbar_me"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_meS"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    
    //我是设计师
    WUFindViewController *findShokeeperVC = [[WUFindViewController alloc] init];
    UINavigationController *findShokeeperNavC = [[UINavigationController alloc] initWithRootViewController:findShokeeperVC];
    findShokeeperNavC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"发现" image:[[UIImage imageNamed:@"tabbar_find"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_findS"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    
    
    WUMessViewController *MessageVC=[[WUMessViewController alloc]init];
    UINavigationController *MessageNav=[[UINavigationController alloc]initWithRootViewController:MessageVC];
    MessageNav.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"消息" image:[[UIImage imageNamed:@"tabbar_message"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_messageS"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    
    YHYMViewViewController *MainShokeeperVC = [[YHYMViewViewController alloc] init];
    UINavigationController *MainShokeeperNavC = [[UINavigationController alloc] initWithRootViewController:MainShokeeperVC];
    MainShokeeperNavC.tabBarItem = [[UITabBarItem alloc]initWithTitle:@"我的" image:[[UIImage imageNamed:@"tabbar_me"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal] selectedImage:[[UIImage imageNamed:@"tabbar_meS"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]];
    
    
    self.ntabbar = [[UITabBarController alloc]init];
    self.ntabbar.viewControllers = [NSArray arrayWithObjects:findShokeeperNavC,MessageNav,MainShokeeperNavC, nil];
    self.ntabbar.tabBar.tintColor = HS;
    //线
    self.ntabbar.tabBar.layer.borderWidth = 0.02;
    self.ntabbar.tabBar.layer.borderColor = [UIColor colorWithWhite:0.650 alpha:0.460].CGColor;
    
    self.stabbar = [[UITabBarController alloc] init];
    self.stabbar.viewControllers = [NSArray arrayWithObjects:findNavC,messageNC,MainNavC,nil];
    self.stabbar.tabBar.tintColor = HS;
    //线
    self.stabbar.tabBar.layer.borderWidth = 0.02;
    self.stabbar.tabBar.layer.borderColor = [UIColor colorWithWhite:0.650 alpha:0.460].CGColor;

  
    //self.window.rootViewController = self.stabbar;
    //设置rootVC
    MainViewController *mainVC = [[MainViewController alloc]init];
    UINavigationController *mainNavC = [[UINavigationController alloc]initWithRootViewController:mainVC];
    self.window.rootViewController = mainNavC;
    
    MainViewController *mainShokeeperVC = [[MainViewController alloc]init];
    UINavigationController *mainShokeeperNavC = [[UINavigationController alloc]initWithRootViewController:mainShokeeperVC];
    self.window.rootViewController = mainShokeeperNavC;
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(ChangeRootVCNotificationcenter:) name:@"ChangeNameNotification" object:nil];
    
    return YES;
}

- (void)ChangeRootVCNotificationcenter:(NSNotification *)notification{
    if ([[notification.userInfo objectForKey:@"select"]isEqualToString:@"2"]) {
        self.window.rootViewController = self.stabbar;
    }
    
    if ([[notification.userInfo objectForKey:@"select"]isEqualToString:@"1"]) {
        self.window.rootViewController = self.ntabbar;
        
    }
}

- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

- (void)applicationDidBecomeActive:(UIApplication *)application {
    // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

@end
